<template>
	<view class="index-box" v-if="init">
		<data-list ref='list' />
	</view>
</template>

<script>
	import dataList from '../components/index.vue'
	export default {
		components: {
			dataList
		},
		data() {
			return {
				init: false
			}
		},
		onLoad() {
			if (!this.vuex_user.delivery_address) {
				uni.showModal({
					content: '你还不是团长，是否申请为团长',
					success: (res) => {
						if (res.confirm) {
							this.$linkTo(`/package/userSuper/pickUp/headoapplication/index`, 'redirectTo')
						} else if (res.cancel) {
							this.uniBack()
						}
					}
				})
			} else {
				this.$loading()
				this.$GetQueryDataList('b_product_delivery_address', 1, 1, {
					manage_id: this.vuex_user.pk_id
				}).then(res => {
					this.$hide()
					if (res.data[0].status != '1') {
						uni.showModal({
							content: '你的申请信息还在审核中，请耐心等待',
							showCancel: false,
							success: (res) => {
								this.$linkTo(`/package/user/user-info/headofapplication`, 'redirectTo')

							}
						})
					} else {
						this.init = true
						this.$initPage()
					}
				})
			}
		},
		onShow() {
			if (this.init) {
				this.$initPage()
			}
		},
		onReachBottom() {
			this.$refs.list.$loadMore()
		},
		methods: {
			$initPage() {
				this.$nextTick(() => {
					this.$refs.list.initPage({
						address: this.vuex_user.delivery_address,
						business_id: this.vuex_business.pk_id,
						pay_status: 1,
						name: ''
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.index-box {
		width: 100%;
		padding: 24rpx 0;

	}
</style>
